#Combinations main analysis
#Table E1 and E2
set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__gov_battle_deaths_escalation", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__gov_battle_deaths_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__gov_battle_deaths_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__gov_battle_deaths_escalation", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__gov_battle_deaths_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__gov_battle_deaths_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__gov_battle_deaths_escalation", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__gov_battle_deaths_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__gov_battle_deaths_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__gov_battle_deaths_escalation__spillover", "mk_onset")]
t<-t[which(t$combo__gov_battle_deaths_escalation__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__gov_battle_deaths_escalation__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__gov_battle_deaths_escalation__spillover", "mk_onset")]
t<-t[which(t$combo__gov_battle_deaths_escalation__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__gov_battle_deaths_escalation__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__gov_battle_deaths_escalation__spillover", "mk_onset")]
t<-t[which(t$combo__gov_battle_deaths_escalation__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__gov_battle_deaths_escalation__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__gov_battle_deaths_escalation__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__gov_battle_deaths_escalation__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__gov_battle_deaths_escalation__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__gov_battle_deaths_escalation__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__gov_battle_deaths_escalation__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__gov_battle_deaths_escalation__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__gov_battle_deaths_escalation__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__gov_battle_deaths_escalation__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__gov_battle_deaths_escalation__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__gov_battle_deaths_escalation__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__gov_battle_deaths_escalation__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__gov_battle_deaths_escalation__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__gov_battle_deaths_escalation__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__gov_battle_deaths_escalation__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__gov_battle_deaths_escalation__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__gov_battle_deaths_escalation__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__gov_battle_deaths_escalation__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__gov_battle_deaths_escalation__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__gov_battle_deaths_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__gov_battle_deaths_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__gov_battle_deaths_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__gov_battle_deaths_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__gov_battle_deaths_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__gov_battle_deaths_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__gov_battle_deaths_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__gov_battle_deaths_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__gov_battle_deaths_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")



set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__gov_battle_deaths_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__gov_battle_deaths_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__gov_battle_deaths_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__gov_battle_deaths_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__gov_battle_deaths_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__gov_battle_deaths_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__gov_battle_deaths_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__gov_battle_deaths_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__gov_battle_deaths_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")



set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__spillover", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__spillover", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__spillover", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")



set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__reb_deaths_civilians_escalation__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__reb_deaths_civilians_escalation__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__reb_deaths_civilians_escalation__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__reb_deaths_civilians_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__reb_deaths_civilians_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__reb_deaths_civilians_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__reb_deaths_civilians_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__reb_deaths_civilians_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__reb_deaths_civilians_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__reb_deaths_civilians_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__reb_deaths_civilians_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__reb_deaths_civilians_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")



set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__reb_deaths_civilians_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__reb_deaths_civilians_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__reb_deaths_civilians_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__reb_deaths_civilians_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__reb_deaths_civilians_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__reb_deaths_civilians_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__reb_deaths_civilians_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__reb_deaths_civilians_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__reb_deaths_civilians_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")



set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__spillover__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__spillover__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__spillover__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__spillover__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__spillover__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__spillover__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__spillover__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__spillover__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__spillover__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")



set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__spillover__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__spillover__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__spillover__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__spillover__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__spillover__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__spillover__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__spillover__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__spillover__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__spillover__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")



set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_attempt__spillover", "mk_onset")]
t<-t[which(t$combo__pt_attempt__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_attempt__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")
#No observations of this combo

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_attempt__spillover", "mk_onset")]
t<-t[which(t$combo__pt_attempt__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_attempt__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_attempt__spillover", "mk_onset")]
t<-t[which(t$combo__pt_attempt__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_attempt__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__spillover", "mk_onset")]
t<-t[which(t$combo__pt_success__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")
#No observations of this combo
set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__spillover", "mk_onset")]
t<-t[which(t$combo__pt_success__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__spillover", "mk_onset")]
t<-t[which(t$combo__pt_success__spillover>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__spillover")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__nonviolent_protest_escalation__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__nonviolent_protest_escalation__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__nonviolent_protest_escalation__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__nonviolent_protest_escalation__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__nonviolent_protest_escalation__protesterviolence_escalation>-99), ]
m<-list()
countries<-unique(t$iso3c)
countries<-countries[-28]
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__nonviolent_protest_escalation__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__nonviolent_protest_escalation__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__nonviolent_protest_escalation__protesterviolence_escalation>-99), ]
m<-list()
countries<-unique(t$iso3c)
countries<-countries[-28]
countries<-countries[-129]
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__nonviolent_protest_escalation__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__nonviolent_protest_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__nonviolent_protest_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__nonviolent_protest_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__pt_success__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__pt_success__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__pt_success__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")



set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=1, sigtest="shuffle.surrogate")


set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=5, sigtest="shuffle.surrogate")

set.seed(042902)
t<-data_test[which(data_test$all==1), c("iso3c", "combo__unsuccessful_coup__protesterviolence_escalation", "mk_onset")]
t<-t[which(t$combo__unsuccessful_coup__protesterviolence_escalation>-99), ]

m<-list()
countries<-unique(t$iso3c)
for (i in 1:length(countries)){
  d<-as.matrix(t[t$iso3c==countries[i], c("mk_onset", "combo__unsuccessful_coup__protesterviolence_escalation")]) 
  m[[i]]<-d
}
CC.eca.aggregated.ts(m, delT = 4, tau=9, sigtest="shuffle.surrogate")
